package cn.driver.manager.service.impl;

import cn.driver.common.pojo.Admin;
import cn.driver.manager.mapper.AdminMapper;
import cn.driver.manager.service.AdService;
import cn.driver.manager.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdServiceImpl implements AdService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin getAdmin(String adminName, String password) {
        return adminMapper.getAdmin(adminName,password);
    }

    @Override
    public List<Admin> getAdminList(int pageNo, int pageSize, String prm) {
        return adminMapper.getAdminList((pageNo-1)*pageSize,pageSize,prm);
    }

    @Override
    public int selectAdmin(String prm) {
        return adminMapper.selectAdmin(prm);
    }

    @Override
    public Admin selectOne(int account) {
        return adminMapper.selectOne(account);
    }

    @Override
    public int addAdmin(Admin admin) {
        return adminMapper.addAdmin(admin);
    }

    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateAdmin(admin);
    }

    @Override
    public int delete(String account) {
        return adminMapper.delete(account);
    }

    @Override
    public Pager<Admin> pageInfo(int pageNo, int pageSize, String prm) {
        Pager<Admin> pager = new Pager<>();
        pager.setPageNo(pageNo);
        pager.setPageSize(pageSize);
        pager.setList(this.getAdminList(pageNo,pageSize,prm));
        pager.setTotalCount(this.selectAdmin(prm));
        return pager;
    }
}
